<template>
	<view class="wrap">
		<u-form :model="model" :rules="rules" ref="uForm" :errorType="errorType">
			<u-form-item :leftIconStyle="{color: '#888', fontSize: '32rpx'}" label-width="140"
				:label-position="labelPosition" label="工作名称" prop="name">
				<u-input :border="border" placeholder="请输入工作名称" v-model="model.name" type="text"></u-input>
			</u-form-item>
			<u-form-item :label-position="labelPosition" label="工作经验" prop="yearLimit" label-width="140">
				<u-input  :border="border" placeholder="请输入工作经验" v-model="model.yearLimit" />
			</u-form-item>
			<u-form-item :label-position="labelPosition" label="公司名称" prop="company" label-width="140">
				<u-input :border="border"  v-model="model.company"
					placeholder="请输入公司名称"></u-input>
			</u-form-item>
			<u-form-item :label-position="labelPosition" label="工资" prop="salary" label-width="140">
				<u-input :border="border"   v-model="model.salary"
					placeholder="请输入工资" ></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" 
				:label-position="labelPosition" label="工作地点" prop="address" label-width="140">
				<u-input :border="border" placeholder="请输入工作地点" v-model="model.address"></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" 
				:label-position="labelPosition" label="学历" prop="degree" label-width="140">
				<u-input :border="border" placeholder="请输入学历" v-model="model.degree"></u-input>
			</u-form-item>
			
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}"
				:label-position="labelPosition" label="联系人" prop="degree" label-width="140">
				<u-input :border="border" placeholder="请输入联系人" v-model="model.contact"></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}"
				:label-position="labelPosition" label="联系方式" prop="degree" label-width="140">
				<u-input :border="border" placeholder="请输入联系方式" v-model="model.contactPhone"></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}"
				:label-position="labelPosition" label="邮箱" prop="degree" label-width="140">
				<u-input :border="border" placeholder="请输入邮箱" v-model="model.email"></u-input>
			</u-form-item>
			
			
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" 
				:label-position="labelPosition" label="招聘数量" prop="count" label-width="140">
				<u-input :border="border" placeholder="请输入招聘数量" v-model="model.count"></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}"
				:label-position="labelPosition" label="截止日期" prop="dueDate" label-width="140">
				<u-input :border="border" :select-open="dueDateShow" type="select" placeholder="请选择截止日期" v-model="model.dueDate"  @click="dueDateShow = true"></u-input>
			</u-form-item>
			<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}"
				:label-position="labelPosition" label="招聘详情" prop="count" label-width="140">
				<u-input :border="border" type="textarea" placeholder="请输入招聘详情" v-model="model.content"></u-input>
			</u-form-item>
			
		</u-form>
			<u-calendar v-model="dueDateShow"  max-date="2050-01-01"  @change="dueDateChange"></u-calendar>
		<u-button type="primary" @click="submit">发布招聘</u-button>
	</view>
</template>
<script>
	export default {
		data() {
			let that = this;
			return {
				model: {
					name: '', //工作名称
					yearLimit: '', //工作经验
					company: '', //公司
					salary:'',//工资
					address: '', //服务地区
					degree:'',//学历
					content: '', //内容
					count: '', //招聘数量
					dueDate:'',//截止日期
					contactPhone:'',//联系方式
					contact:'',//联系人
					email:'',//邮箱
				},
				dueDateShow:false,
				selectList: [],
				rules: {
					name: [{
						required: true,
						message: '请输入名称',
						trigger: 'blur',
					}],
					address: [{
						required: true,
						message: '请选择地区',
						trigger: 'change',
					}],
					buildCost: [{
						required: true,
						message: '请选择服务报价',
						trigger: 'change',
					}],
					content: [{
						required: true,
						message: '请输入设备服务描述',
						trigger: 'blur',
					}],
					phone: [{
						required: true,
						message: '请输入联系电话',
						trigger: ['change', 'blur'],
					}],
				},
				border: false,
				labelPosition: 'left',
				errorType: ['message'],
			};
		},
		onLoad() {
			//this.baseUrl = this.baseUrl;
			//this.getDictData();
		},
		computed: {

		},
		onReady() {
			//this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			submit() {
                this.jobNew();
				// this.$refs.uForm.validate(valid => {
				// 	if (valid) {
				// 		this.jobNew();
				// 	} else {
				// 		console.log('验证失败');
				// 	}
				// });
			},
			getDictData() {

				this.$u.api.getDictData({
						dictType: "sys_service"
					})
					.then(res => {
						this.services = res.rows;
						console.log(res);
					});


			},
			jobNew() {
				this.$u.api.jobNew(this.model)
					.then(res => {
						this.$u.toast('发布成功');
						uni.navigateBack();
						
					});
			},
			dueDateChange(e)
			{
				this.model.dueDate=e.result;
				console.log(e.result);
			}
		}
	};
</script>

<style scoped lang="scss">
	.wrap {
		padding: 30rpx;
	}

	.agreement {
		display: flex;
		align-items: center;
		margin: 40rpx 0;

		.agreement-text {
			padding-left: 8rpx;
			color: $u-tips-color;
		}
	}
</style>
